#include <stdio.h>
#define M 1000001
int minq[M],ind1[M],f1=1,b1=0;
void pushmin(int num, int ind) {
	minq[++b1]=num;
	ind1[b1]=ind;
	while(minq[b1-1]>minq[b1]&&b1>f1) {
		minq[b1-1]=minq[b1];
		ind1[b1-1]=ind1[b1];
		b1--;
	}
}
int tmp[M];
int main() {
	int n,w,i,j,a,sum2=0,sum=0,ans=0;
	scanf("%d", &n);
	for(i=1;i<=n;i++) {
		scanf("%d",&tmp[i]);
		sum2+=tmp[i];
		pushmin(sum2,i);
	}
	for(i=1;i<n;i++) {
		printf("%d %d\n",sum,minq[f1]);
		if(sum>=minq[f1])
			ans++;
		if(i-n>=ind1[f1]-1)
			f1++;
		pushmin(sum+sum2,i);
		sum+=tmp[i];
	}
	printf("%d",ans);
	return 0;
}
